package com.ff.neuropp.repository;

import com.ff.neuropp.domain.Contacts;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import javax.transaction.Transactional;
import java.util.Date;


public interface ContactsRepository extends JpaRepository<Contacts, Integer> {

    @Transactional
    @Modifying
    @Query(value = "update t_contacts set " +
            "status= :status , " +
            "update_time= :updateTime," +
            "apply_status= :applyStatus, " +
            "reason= :reason " +
            "where user_id =:userId and contact_id = :contactId",nativeQuery = true)
    int update(@Param("status") Integer status,
               @Param("updateTime") Date updateTime,
               @Param("applyStatus") Integer applyStatus,
               @Param("reason") String reason,
               @Param("userId") String userId,
               @Param("contactId") String contactId);
}
